<template>
	<view>
		<baseHead :showReturn="true" title="感兴趣" bg="#fff" :showIcon="false" color="#000"></baseHead>
		<scroll-view scroll-y class="scrollview" @scrolltolower="ReachBottom" v-if="datalist.length > 0"
			refresher-enabled='true' refresher-default-style='none' refresher-background='#f1f2f6'
			refresher-threshold='15' :refresher-triggered='loading' @refresherrefresh="onrefresh">
			<u-loading-icon v-if="loading"></u-loading-icon>
			<view v-for="(item, index) in datalist" :key="index">
				<!-- <uni-swipe-action v-if="datalist" class="swipeAction"> -->
				<!-- <uni-swipe-action-item class="jiaonliguanli" @click="handleXingqu(item, index)"
						:show="item.isOpened" :class="{ active: isShow }" :right-options="options1"
						@change="handgxqchange($event,index)" :autoClose="false" :disabled="isShow"
						v-if="item.JobExpect"> -->
				<view class="swipeAction" @click="JobDetails(item)">
					<view class="jiaonliguanli">
						<view class="swipe-in-item">
							<view class="check" v-show="isShow">
								<view class="radio-check">
									<u-icon class="iconcheck" v-if="item.checked == true" color="#1684FC" size="26"
										name="checkmark-circle-fill"></u-icon>
									<view v-if="item.checked == false" class="active"></view>
								</view>
							</view>
							<view class="view-layout">
								<view class="view-left">
									<view class="avatar">
										<u-avatar class="avatar-img" :size="54" shape="circle" :src="URL + item.Avatar">
										</u-avatar>
										<u--image class="avatar-sex" :src="
								  item.Sex == 1
								    ? '/static/image/my/man.png'
								    : '/static/image/my/woman.png'
								" width="32rpx" height="32rpx"></u--image>
									</view>
									<view class="tips">
										<span>{{ item.Age }}岁</span>
									</view>
								</view>
								<view class="view-right">
									<view class="view-right-top">
										<view class="view-right-top-left">
											<span class="name">{{ item.Name }}</span>
											<view class="tipss">
												<span v-if="item.CurrentRole == 0">职场人</span>
												<span v-if="item.CurrentRole == 1">学生</span>
											</view>
										</view>
										<view class="xinzi">
											<span v-if="item.JobExpect.Negotiable" class="money">可面议</span>
											<span v-else
												class="money">{{ numberFormat(item.JobExpect.MinWage, true) }}~{{
								    numberFormat(item.JobExpect.MaxWage)
								  }}</span>
										</view>
									</view>
									<view class="view-info">
										<span>{{ item.EducationLevelStr }}</span>
										<view class="xian" v-if="item.EducationLevelStr"></view>
										<span>
											{{item.WorkYear == -1 ?'在校生': item.WorkYear == 0 ? '应届生': item.WorkYear+'年经验'+ ' '}}</span>
										<view class="xian" v-if=" item.WorkYear"></view>
										<span>{{ item.JobExpect.WorkTypeStr }}</span>
										<view class="xian" v-if="item.JobExpect.WorkTypeStr"></view>
										<span>{{ item.CurrentStatusStr }}</span>
									</view>
									<view class="view-info ">
										<view class="view-info-text">
											期望职位：{{
								  item.JobExpect.PositionName ||
								  item.JobExpect.CustomPositionName
								}}
										</view>
										<!-- <view class="view-info-text">期望城市：{{ item.JobExpect.PcaAddress }}</view> -->
									</view>

								</view>
							</view>
						</view>
					</view>
				</view>

				<!-- </uni-swipe-action-item>
				</uni-swipe-action> -->

			</view>

			<u-loadmore :status="status" style="height: 80rpx;margin-top: 0;margin-bottom: 0;" />
		</scroll-view>
		<u-empty v-else mode="data" icon="/static/recruit/index/qsy.png" width="350" marginTop="150">
		</u-empty>
	</view>
</template>

<script>
	import baseHead from "@/pages/component/baseHead.vue";
	export default {
		//子组件
		components: {
			baseHead,
		},
		data() {
			return {
				URL: this.$config.domain.staticUrl,
				Id: '',
				datalist: [],
				obj: {
					PageIndex: 1,
					PageSize: 10,
				},
				status: "loadmore",
				loading: false,
				isShow: false,
			}
		},
		onLoad(e) {
			this.Id = e.Id;
		},
		created() {
			this.listdata();
		},
		// 下拉刷新
		onPullDownRefresh() {
			this.obj = {
				PageIndex: 1,
				PageSize: 10,
			};
			this.listdata();
			uni.stopPullDownRefresh(); //停止刷新
		},
		onReachBottom() {
			// 加载前值为loadmore，加载中为loading，没有数据为nomore
			if (this.status != "nomore") {
				this.status = "loading";
				this.listdata();
			}
		},
		methods: {
			//列表上拉刷新
			onrefresh() {
				this.loading = true;
				setTimeout(() => {
					this.loading = false;
					this.datalist = [];
					this.listdata();
				}, 1000);
			},
			listdata(val) {
				let obj = {
					PageIndex: this.obj.PageIndex,
					PageSize: this.obj.PageSize,
				};
				if (this.Id == undefined) {
					obj.JobId = null
				} else {
					obj.JobId = this.Id
				}
				this.$http.huirc.collectionlistByJob(obj).then((res) => {
					if (res.Result) {
						if (this.obj.PageIndex == 1 && res.Result.Items.length == 0) {
							this.datalist = [];
						} else {
							if (res.Result.Items.length == 0) {
								// 没有数据----
								this.status = "nomore";
								return;
							}
							this.datalist = this.datalist.concat(res.Result.Items)
								.map((item) => {
									return {
										...item,
										checked: false,
										isOpened: 'none'
									};
								});
						}

						if (res.Result.Items.length >= this.obj.PageSize) {
							this.obj.PageIndex++;
							// 表示还有数据
						} else {
							//没有更多数据了
							this.status = "nomore";
						}
					}
				});
			},
			numberFormat(num, val) {
				let newNum = num / 1000;
				newNum = newNum.toString();
				const index = newNum.indexOf(".");
				if (index !== -1) {
					if (!val) {
						return parseFloat(newNum).toFixed(1) + "k";
					} else {
						return parseFloat(newNum).toFixed(1);
					}
				} else {
					if (!val) {
						return parseFloat(newNum) + "k";
					} else {
						return parseFloat(newNum);
					}
				}
			},
			ReachBottom() {
				if (this.status != "nomore") {
					this.listdata()
				}
			},
			JobDetails(item) {
				let int = item.JobExpectId;
				uni.navigateTo({
					url: `/pages/views/packageA/type-recruit/search/JobDetails?key=${int}`,
					
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	.swipeAction {
		box-sizing: border-box;
		padding: 0rpx 20rpx;
	}

	.iconcheck {
		span {
			width: 43rpx;
			height: 40rpx;
			overflow: hidden;
		}
	}

	.radio-check {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 43rpx;
		height: 40rpx;
		// overflow: hidden;
		margin-right: 15rpx;

		.active {
			width: 43rpx;
			height: 40rpx;
			border-radius: 50%;
			border: 2rpx solid #666666;
		}
	}

	.scrollview {
		height: calc(100vh - 198rpx);
		box-sizing: border-box;
	}

	.isTop {
		padding-bottom: 100rpx;
	}

	.jiaonliguanli {
		border-radius: 20rpx;
		background-color: #ffffff;
		margin-top: 20rpx;

		// display: flex;
		// justify-content: space-between;
		// width: 100%;
		// flex: 1;
		.u-swipe-action-item {}

		.swipe-in-item {
			padding: 10rpx 30rpx;
			padding-right: 0;
			display: flex;
			// width: 100%;
			width: 103%;
			flex: 1;

			.check {
				display: flex;
				align-items: center;
				// margin-right: 15rpx;
			}

			.view-layout {
				width: 90%;
			}
		}

		&.active {
			.swipe-in-item {
				background-color: #f9f9f9;
			}

			.view-layout {
				background-color: #ffffff;
				padding: 20rpx;
			}
		}

		.view-layout {
			display: flex;
			justify-content: space-between;
			padding: 20rpx 0;
		}

		.view-right {
			margin-left: 25rpx;
			flex: 1;
			display: flex;
			flex-direction: column;
			align-content: space-between;
			justify-content: space-between;
			padding-bottom: 8rpx;

			.view-right-top {
				width: 100%;
				display: flex;
				justify-content: space-between;
				border-radius: 4rpx;
				margin-top: 10rpx;

				.view-right-top-left {
					display: flex;
					align-items: center;

					.name {
						color: #000000;
						font-weight: 500;
						margin-right: 10rpx;
					}

					.tipss {
						padding: 5rpx 17rpx;
						border-radius: 10rpx;
						opacity: 1;
						border: 1rpx solid #476DF0;
						font-size: 24rpx;
						font-weight: 400;
						color: #476DF0;
						display: flex;
						justify-content: center;
						align-items: center;
					}
				}


				.money {
					margin-left: 20rpx;
					font-size: 34rpx;
					font-weight: 400;
					color: #F35370;
				}



				.border-tips {
					// border: 1px solid #E9E9E9;
					display: flex;
					align-items: center;
					color: #666666;
					font-size: 26rpx;

					padding: 5rpx 20rpx span {
						margin-left: 10rpx;
					}
				}
			}

			.view-info {
				margin-top: 20rpx;
				display: flex;
				align-items: center;

				span {
					font-size: 24rpx;
					color: #313131;
					padding: 0 12rpx;
					line-height: 24rpx;

					&:first-child {
						padding-left: 0;
					}

					&:last-child {
						border-right: 0;
					}

				}

				.xian {
					width: 0rpx;
					height: 16rpx;
					opacity: 0.2;
					border: 1rpx solid #707070;
				}

				.view-info-text {
					// width: 49%;
					font-size: 24rpx;
					color: #313131;
					word-break: keep-all;
					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis;
					margin-top: 6rpx;
				}

				&.flex {
					display: flex;
					justify-content: space-between;
				}
			}

			.view-jieshao {
				margin-top: 25rpx;
				color: #000000;
				font-size: 24rpx;
				text-overflow: -o-ellipsis-lastline;
				overflow: hidden;
				text-overflow: ellipsis;
				display: -webkit-box;
				-webkit-line-clamp: 2;
				line-clamp: 2;
				-webkit-box-orient: vertical;
			}
		}

		.viewtext {
			padding: 10rpx 0rpx;
		}

		.textmianst {
			border: 1px solid #e9e9e9;
			margin-left: 40rpx;
			font-size: 20rpx;
			padding: 5rpx 20rpx;
		}

		.potstycp {
			position: absolute;
			top: 20rpx;
			right: 40rpx;
		}

		.potstpth {
			position: absolute;
			bottom: 20rpx;
			background-color: #f1f2f6;
			right: 40rpx;
			padding: 10rpx 20rpx;
			border-radius: 10rpx;
		}
	}

	.avatar {
		position: relative;
		display: flex;
		width: 108rpx;
		height: 108rpx;

		.avatar-img {
			position: absolute;
		}

		.avatar-sex {
			position: absolute;
			right: 0;
			bottom: 0;

			span {
				background-color: #fff;
				color: #fff;
			}
		}
	}

	.tips {
		margin-top: 20rpx;
		font-size: 24rpx;
		font-weight: 400;
		color: #000000;
		text-align: center;
	}

	.fiexd {
		position: fixed;
		bottom: 0;
		width: 100%;
		background-color: #fff;
		box-shadow: 0px 0px 5px 1px rgba(131, 140, 149, 0.14);
		z-index: 99999;

		.grid-text {
			font-size: 28rpx;
			line-height: 98rpx;
		}

		.fiexd-cont {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 20rpx 20rpx;


			.btnbox2 {
				padding: 16rpx 50rpx;
				background: #3476FE;
				border-radius: 10rpx;
				opacity: 1;
				display: flex;
				align-items: center;
				justify-content: center;

				.btntext {
					font-size: 26rpx;
					font-weight: 400;
					color: #FFFFFF;
				}
			}
		}
	}
</style>